/*
 * This file is Copyright 2002-2006 Loyola University Chicago,
 * Department of Computer Science and the Emerging Technologies Laboratory.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License via
 *    http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.citep.business.sessions;

import com.citep.business.*;

import java.util.Date;
import java.util.List;
import java.math.BigDecimal;

public interface TransactionSession {

	public Transaction getTransaction(int id);
	
	public Transaction createTransaction(Transaction t);
	public Transaction createTransaction(User u, Date transactionTime, String memo);
	
	public void updateTransaction(Transaction t) throws InvalidTransactionStateException;

	public void deleteTransaction(int id);
	public void deleteTransaction(Transaction t);
	
//	protected void addEntry(Transaction t, Account account, String memo, BigDecimal amount, EntryTypes type) throws InvalidTransactionStateException;
	
	/*
	 * Transfer from source to dest.
	 * The type (credit or debit) refers to the source account. The destination account entry will be the opposite type.
	 */
	public void transfer(User user, Account source, Account dest, EntryTypes type, String memo, Date transactionDate, BigDecimal amount);
	
	/*
	 * Gets an account's balance up to and including this transaction
	 */
	public BigDecimal getAccountBalance(Account account, Transaction t);
	
	/*
	 * Gets an account's balance up to and including this entry
	 */
	public BigDecimal getAccountBalance(Account account, int entryId);
	
	public List<Transaction> getTransactions();
	public List<Transaction> getTransactions(User u);
	public List<Transaction> getTransactions(Date startDate, Date endDate);
	public List<Transaction> getTransactions(Account a, int offset, int limit);
	
	public List<Entry> getEntries(User u);
	public List<Entry> getEntries(Date startDate, Date endDate);
	public List<Entry> getEntries(Account a, int offset, int limit);
	
	//returns the time when the latest transaction was modified (all accounts)
	public Date getLatestTransactionTime();	
	//returns the time when the latest transaction was modified for account a
	public Date getLatestTransactionTime(Account a);
}
